package top.zhangjianyong.netty.nio;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

public class FileNio {
    public static void main(String[] args) throws IOException {
        FileInputStream fileInputStream =new FileInputStream("123");
        FileOutputStream fileOutputStream =new FileOutputStream("abc");

        FileChannel ic = fileInputStream.getChannel();
        FileChannel oc = fileOutputStream.getChannel();

        ByteBuffer byteBuffer=ByteBuffer.allocateDirect(1024);

        ic.read(byteBuffer);

        byteBuffer.flip();
        oc.write(byteBuffer);

        fileInputStream.close();
        fileOutputStream.close();
    }
}
